#include <iostream>
#include <memory>
using namespace std;
class Child;
class Parent{
public:
    Parent()
    {cout << "Parent()"<<endl;}
    ~Parent()
    {cout << "~Parent()"<<endl;}
    shared_ptr<Child> _spChild;
};
class Child{
public:
    Child()
    {cout<< "Child()"<<endl;}
    ~Child()
    {cout<<"~Child()"<<endl;}
    weak_ptr<Parent>_spParent;
};
void test(){
   shared_ptr<Parent> parentPtr(new Parent());
   shared_ptr<Child> childPtr(new Child());
   parentPtr ->_spChild = childPtr;
   childPtr ->_spParent = parentPtr;
   cout << "ParentPtr.use.count()" << parentPtr.use_count()<<endl;
   cout << "childPtr.use.count()" << childPtr.use_count() <<endl;
}
int main()
{
    test();
    return 0;
}

